<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>旋转</title>
</head>
<body>


<script>
    function draw() {


    var c=document.getElementById("myCanvas");
    var ctx=c.getContext("2d");
        ctx.translate(200,150);
    ctx.rotate(8*Math.PI/180);
    ctx.strokeRect(0,0,100,20);
        ctx.translate(-200,-150);}
</script>
<canvas id="myCanvas" width="600" height="400" style="border:1px solid #d3d3d3;">
</canvas>
<p><button type="button" onclick="draw();">绘图</button></p>
</body>
</html>